package io.qytc.jboot.utils;

import java.util.Random;

/**
 * 生成随机数
 */
public class GenCodeUtils {

    public static String randomCode(String base,Integer length){

        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();

    }

    public static String genToken(){
        String token = GenCodeUtils.randomCode("1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", 32);
        return token;
    }

}
